this._updateState();
}));
- this._isScreenLocked = false;
- Main.screenShield.connect('lock-status-changed', Lang.bind(this, this._onScreenLockStatusChanged));
+ Main.sessionMode.connect('updated', Lang.bind(this, this._updateState));
global.display.add_keybinding('toggle-message-tray',
new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
this._notificationQueue.splice(index, 1);
},
- _onScreenLockStatusChanged: function(screenShield, locked) {
- this._isScreenLocked = locked;
- this._updateState();
- },
-
_lock: function() {
this._locked = true;
},
_updateState: function() {
// Notifications
let notificationQueue = this._notificationQueue.filter(Lang.bind(this, function(notification) {
- if (this._isScreenLocked)
- return notification.showWhenLocked;
- else
- return true;
+ return notification.showWhenLocked || Main.sessionMode.hasNotifications;
}));
let notificationUrgent = notificationQueue.length > 0 && notificationQueue[0].urgency == Urgency.CRITICAL;
// notificationsLimited is false when the screen is locked, because they go through
// different filtering, and we want to show non urgent messages at times
- let notificationsLimited = (this._busy || this._inFullscreen) && !this._isScreenLocked;
+ let notificationsLimited = (this._busy || this._inFullscreen) && Main.sessionMode.hasNotifications;
let notificationsPending = notificationQueue.length > 0 && (!notificationsLimited || notificationUrgent);
let nextNotification = notificationQueue.length > 0 ? notificationQueue[0] : null;
let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
!this._pointerInTray &&
!this._locked &&
!(this._pointerInKeyboard && notificationExpanded);
- let notificationLockedOut = this._isScreenLocked && (this._notification && !this._notification.showWhenLocked);
+ let notificationLockedOut = !Main.sessionMode.hasNotifications && (this._notification && !this._notification.showWhenLocked);
// TODO: how to deal with locked out notiifcations if want to keep showing notifications?!
let notificationMustClose = this._notificationRemoved || notificationLockedOut || (notificationExpired && this._userActiveWhileNotificationShown) || this._notificationClosed;
let canShowNotification = notificationsPending && this._summaryState == State.HIDDEN;
let summaryOptionalInOverview = this._overviewVisible && !this._locked && !summaryHovered;
let mustHideSummary = (notificationsPending && (notificationUrgent || summaryOptionalInOverview))
- || notificationsVisible || this._isScreenLocked;
+ || notificationsVisible || !Main.sessionMode.hasNotifications;
if (this._summaryState == State.HIDDEN && !mustHideSummary && summarySummoned)
this._showSummary();
this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });
this._isModal = false;
- this._isLocked = false;
this._hasLockScreen = false;
+ this._isGreeter = false;
+ this._isActive = false;
this._lightbox = new Lightbox.Lightbox(Main.uiGroup,
{ inhibitEvents: true,
// If we have a unlock dialog, cancel it
if (this._dialog) {
this._dialog.cancel();
- if (!this._keepDialog) {
+ if (!this._isGreeter) {
this._dialog = null;
}
}
if (status == GnomeSession.PresenceStatus.IDLE) {
if (this._dialog) {
this._dialog.cancel();
- if (!this._keepDialog) {
+ if (!this._isGreeter) {
this._dialog = null;
}
}
this._isModal = true;
}
- if (!this._isLocked)
+ if (!this._isActive)
this._lightbox.show();
} else {
let lightboxWasShown = this._lightbox.shown;
this._lightbox.hide();
let shouldLock = lightboxWasShown && this._settings.get_boolean(LOCK_ENABLED_KEY);
- if (shouldLock || this._isLocked) {
+ if (shouldLock || this._isActive) {
this.lock(false);
} else if (this._isModal) {
this.unlock();
},
showDialog: function() {
- this.lock(true);
+ if (!this._isModal) {
+ Main.pushModal(this.actor);
+ this._isModal = true;
+ }
+
+ this.actor.show();
+ this._isGreeter = Main.sessionMode.isGreeter;
this._ensureUnlockDialog();
this._hideLockScreen(false);
},
time: time,
transition: 'linear',
onComplete: function() {
- this._lockScreenHidden();
+ this._lockScreenState = MessageTray.State.HIDDEN;
+ this._lockScreenGroup.hide();
},
onCompleteScope: this,
});
} else {
- this._lockScreenHidden();
+ this._lockScreenState = MessageTray.State.HIDDEN;
+ this._lockScreenGroup.hide();
}
- },
- _lockScreenHidden: function() {
- this._lockScreenState = MessageTray.State.HIDDEN;
- this._lockScreenGroup.hide();
+ if (Main.sessionMode.currentMode == 'lock-screen')
+ Main.sessionMode.popMode('lock-screen');
},
_ensureUnlockDialog: function() {
if (!this._dialog) {
let constructor = Main.sessionMode.unlockDialog;
this._dialog = new constructor(this._lockDialogGroup);
- this._keepDialog = Main.sessionMode.isGreeter;
if (!this._dialog) {
// This session mode has no locking capabilities
this.unlock();
this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed));
this._dialog.connect('unlocked', Lang.bind(this, this._onUnlockSucceded));
}
-
- if (Main.sessionMode.isGreeter) {
- // Notify the other components that even though we are showing the
- // screenshield, we're not in a locked state
- // (this happens for the gdm greeter)
-
- this._isLocked = false;
- this.emit('lock-status-changed', false);
- }
},
_onUnlockFailed: function() {
},
_resetLockScreen: function(animate) {
+ this._ensureLockScreen();
this._lockDialogGroup.scale_x = 1;
this._lockDialogGroup.scale_y = 1;
}
this._lockScreenGroup.grab_key_focus();
+
+ if (Main.sessionMode.currentMode != 'lock-screen')
+ Main.sessionMode.pushMode('lock-screen');
},
_lockScreenShown: function() {
// Some of the actors in the lock screen are heavy in
// resources, so we only create them when needed
- _prepareLockScreen: function() {
+ _ensureLockScreen: function() {
+ if (this._hasLockScreen)
+ return;
+
this._lockScreenContentsBox = new St.BoxLayout({ x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER,
x_expand: true,
},
get locked() {
- return this._isLocked;
+ return this._isActive;
},
_tweenUnlocked: function() {
},
unlock: function() {
- if (!this._isLocked)
- return;
-
if (this._hasLockScreen)
this._clearLockScreen();
- if (this._dialog && !this._keepDialog) {
+ if (this._dialog && !this._isGreeter) {
this._dialog.destroy();
this._dialog = null;
}
this._isModal = false;
}
- this._isLocked = false;
+ this.actor.hide();
+
+ if (Main.sessionMode.currentMode == 'lock-screen')
+ Main.sessionMode.popMode('lock-screen');
+ if (Main.sessionMode.currentMode == 'unlock-dialog')
+ Main.sessionMode.popMode('unlock-dialog');
- this.emit('lock-status-changed', false);
- Main.sessionMode.popMode('lock-screen');
+ this._isActive = false;
+ this.emit('lock-status-changed');
},
lock: function(animate) {
- if (this._isLocked)
- return;
-
- if (!this._hasLockScreen)
- this._prepareLockScreen();
-
if (!this._isModal) {
Main.pushModal(this.actor);
this._isModal = true;
}
- this._isLocked = true;
this.actor.show();
+
+ if (Main.sessionMode.currentMode != 'unlock-dialog' &&
+ Main.sessionMode.currentMode != 'lock-screen') {
+ this._isGreeter = Main.sessionMode.isGreeter;
+ if (!this._isGreeter)
+ Main.sessionMode.pushMode('unlock-dialog');
+ }
+
this._resetLockScreen(animate);
- this.emit('lock-status-changed', true);
- Main.sessionMode.pushMode('lock-screen');
+ this._isActive = true;
+ this.emit('lock-status-changed');
},
});
Signals.addSignalMethods(ScreenShield.prototype);
hasRunDialog: false,
hasWorkspaces: false,
hasWindows: false,
+ hasNotifications: false,
isLocked: false,
isGreeter: false,
isPrimary: false,
'gdm': {
allowKeybindingsWhenModal: true,
+ hasNotifications: true,
isGreeter: true,
isPrimary: true,
unlockDialog: imports.gdm.loginDialog.LoginDialog,
'lock-screen': {
isLocked: true,
- isGreeter: undefined,
unlockDialog: undefined,
components: ['networkAgent', 'polkitAgent', 'telepathyClient'],
panel: {
},
},
+ 'unlock-dialog': {
+ isLocked: true,
+ unlockDialog: undefined,
+ components: ['networkAgent', 'polkitAgent', 'telepathyClient'],
+ panel: {
+ left: ['userMenu'],
+ center: [],
+ right: ['a11y', 'keyboard', 'lockScreen']
+ },
+ },
+
'initial-setup': {
isPrimary: true,
components: ['keyring'],
hasRunDialog: true,
hasWorkspaces: true,
hasWindows: true,
- unlockDialog: imports.ui.unlockDialog.UnlockDialog,
+ hasNotifications: true,
isLocked: false,
isPrimary: true,
+ unlockDialog: imports.ui.unlockDialog.UnlockDialog,
components: ['networkAgent', 'polkitAgent', 'telepathyClient',
'keyring', 'recorder', 'autorunManager', 'automountManager'],
panel: {
this._sync();
},
+ switchMode: function(to) {
+ if (this.currentMode == to)
+ return;
+ this._modeStack[this._modeStack.length - 1] = to;
+ this._sync();
+ },
+
get currentMode() {
return this._modeStack[this._modeStack.length - 1];
},